<%@ page language="java" pageEncoding="utf-8" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>购票资料列表</title>
    <jsp:include page="/IncludeJS.jsp"></jsp:include>
</head>
<body>
<script type="text/javascript">
    $(function () {
        var pager = $(".easyui-datagrid").datagrid('getPager');
        $(pager).pagination({
            total:${pager.totalRows},
            pageSize:${pager.pageRow},
            displayMsg: '{from}-{to}/{total}',
            pageNumber:${pager.cur_page},
            afterPageText: '页，共{pages}页',
            pageList: [100, 500, 1000, 10000],
            loading: false,
            showPageList: true,
            showRefresh: true,
            //刷新方法
            onBeforeRefresh: function (p, s) {
                location.href = "${pageContext.request.contextPath }/order/list?planId=${planId}&cur_page=" + p + "&pageRow=" + s;
            },
            onSelectPage: function (p, s) {
                location.href = "${pageContext.request.contextPath }/order/list?planId=${planId}&cur_page=" + p + "&pageRow=" + s;
            }
        });
        $('#changesize').datagrid('resize', {
            height: document.body.clientHeight - 45
        });
    });

    function edit() {
        var ids = $('input[name="id"]:checked');
        var len = ids.length;
        if (ids.length == 0) {
            alert("请选择要修改的购票");
            return;
        }
        if (ids.length > 1) {
            alert("只能选择一笔购票");
            return;
        }
        var arr = "";
        ids.each(function (i, d) {
            if ((i + 1) != len) {
                arr += $(d).val() + ",";
            } else {
                arr += $(d).val();
            }
        })
        url = "${pageContext.request.contextPath }/order/update?planId=" + arr;
        location.href = url;
    }

    function getRowData(value, rec) {
        var id = rec.id;
        $("#orderId").val(id);
        $("#mobile").val(rec.mobile);
        $("#hallSeatId").val(rec.hallSeatId);
        $("#salePrice").val(rec.salePrice);
        $("#orderTime").datebox("setValue", rec.orderTime);
        $("#payType").val(rec.payType);
        $("#state").val(rec.state);
    }

    function save() {
        document.forms[1].submit();
    }

    function add() {
        $("#orderId").val(0);
        $("#mobile").val("");
        $("#hallSeatId").val("");
        $("#salePrice").val("");
        $("#state").val("");
        $("#payType").val("");
        var d = new Date();
        $("#orderTime").datebox("setValue", d.getFullYear() + "-" + (d.getMonth() + 1) + "-" + d.getDate());
    }

    function del() {
        var ids = $('input[name="id"]:checked');
        var len = ids.length;
        if (ids.length == 0) {
            alert("请选择要删除的购票");
            return;
        }
        if (!confirm('删除购票确认')) {
            return;
        }
        var arr = "";
        ids.each(function (i, d) {
            if ((i + 1) != len) {
                arr += $(d).val() + ",";
            } else {
                arr += $(d).val();
            }
        })
        var url = "${pageContext.request.contextPath }/order/del?ids=" + arr;
        location.href = url;
    }

    if ("${msg}" != null && "${msg}".length > 0) {
        alert("${msg}");
    }
</script>
<table width="100%" border="0" cellpadding="0" cellspacing="0"
       BACKGROUND="${pageContext.request.contextPath }/images/maintitle.jpg" class="tablelist2">
    <form action="${pageContext.request.contextPath }/order/save" method="post">
        <input type="hidden" name="orderId" id="orderId" value="${order.orderId}">
        <tr class="tableselect2">
            <td align="left">
                <div class="tools">
                    <ul class="toolbar">
                        <!--
						<li><a href="javascript:void(0);" onclick="add();"><span><img src="${pageContext.request.contextPath }/images/add.png"></span>添加</a></li>
						-->
                        <li><a href="javascript:void(0);" onclick="del();"><span><img
                                src="${pageContext.request.contextPath }/images/delete.png"></span>删除</a></li>
                    </ul>
                </div>
            </td>
            <td align="right">
                <input type="hidden" name="orderId" id="orderId" value="0">
                手机号码:<input type="text" name="mobile" id="mobile" style="width:100px">
                座位号:
                <select name="hallSeatId" id="hallSeatId" style="width:120px">
                    <c:forEach items="${seatList}" var="v">
                        <option value="${v.hallSeatId}">${v.seatName}</option>
                    </c:forEach>
                </select>
                价格：<input type="text" name="salePrice" id="salePrice" value="${plan.seatPrice}" readonly="readonly"
                          style="width:100px">
                支付方式:
                <select name="payType" id="payType">
                    <option value="微信">微信</option>
                    <option value="支付宝">支付宝</option>
                    <option value="其他">其他</option>
                </select>
                类别:
                <select name="state" id="state">
                    <option value="购票">购票</option>
                    <option value="退票">退票</option>
                </select>
                <input type="submit" value="保存">
            </td>
        </tr>
    </form>
</table>
<table class="easyui-datagrid" pagination="true" id="changesize" style="width:auto;padding:0px" singleSelect="false"
       data-options="onClickRow:getRowData">
    <thead>
    <tr>
        <th field="id" checkbox="true" width=50>选择</th>
        <th field="mobile" width=100 align="center">手机号码</th>
        <th field="agentName" width=200 align="center">影院</th>
        <th field="hallName" width=150 align="center">影厅</th>
        <th field="movieName" width=150 align="center">电影</th>
        <th field="seatName" width=100 align="center">座位</th>
        <th field="salePrice" width=80 align="center">价格</th>
        <th field="playTimeName" width=150 align="center">放映时间</th>
        <th field="payType" width=80 align="center">支付方式</th>
        <th field="state" width=100 align="center">类别</th>
    </tr>
    </thead>
    <tbody>
    <c:forEach items="${pager.data}" var="v">
        <tr>
            <td>${v.orderId }</td>
            <td>${v.mobile }</td>
            <td>${v.agentName }</td>
            <td>${v.hallName }</td>
            <td>${v.movieName }</td>
            <td>${v.seatName }</td>
            <td>${v.salePrice }</td>
            <td>${v.playDay}${v.playTimeName }</td>
            <td>${v.payType }</td>
            <td><c:if test="${v.state=='购票'}">购票</c:if><c:if test="${v.state=='退票'}">退票</c:if></td>
        </tr>
    </c:forEach>
    </tbody>
</table>
</body>
</html>